package com.yuyang.springcloud.controller;

import com.yuyang.springcloud.entities.CommonResult;
import com.yuyang.springcloud.entities.Payment;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @author yu yang
 * @date 2022/11/3 -23:16
 */
@RestController
public class PaymentController {
    @Value("${server.port}")
    private String serverPort;

    private static HashMap<Long,Payment> hashMap = new HashMap<>();
    static {
        hashMap.put(1L,new Payment(1L,"28a8c1e3bc2742d8848569891fb42181"));
        hashMap.put(2L,new Payment(2L,"bba8c1e3bc2742d8848569891ac32182"));
        hashMap.put(3L,new Payment(3L,"6ua8c1e3bc2742d8848569891xt92183"));
    }

    @GetMapping("/paymentSQL/{id}")
    public CommonResult<Payment> getPaymentById(@PathVariable("id") Long id){
        Payment payment = hashMap.get(id);
        return CommonResult.success(200,"from mysql serverPort："+serverPort,payment);
    }

}
